<template>
<!--  <Button-->
<!--    type="primary"-->
<!--    style="margin-right: 15px;"-->
<!--    v-if="isRuning"-->
<!--    @click="action('revoke')"-->

<!--  >撤回-->

<!--  </Button>-->

</template>
<script>
  import {getProcessInstanceInfo} from '@/api/analy'
  import {
    revokeActivity
  } from '@/api/action'
  export default {
    props: {
      value: {
        type: String,
        default: ''
      },
      taskId: {
        type: String,
        default: ''
      },
      start: {
        type: Boolean,
        default: false
      }
    },
    created() {
      var val = this.value;
      if (val) {
        this.getProcessInstanceInfo(val);
      }
    },
    data() {
      return {
        isRuning: true,
      }
    },
    methods: {
      action: function(action) {

        switch (action) {
          case 'revoke':
            var form={};
            if (this.taskId){
              form['taskId']=this.taskId;
              form['taskTitle']="撤回操作";
              form['option']="option";
              form['processInstanceId']=this.value;
              revokeActivity(form).then((response) => {
                if (response.code == 0) {
                  this.$message({"duration":'800',message:'撤回成功',type:'success',customClass:'zZindex'});

                } else {
                  this.$message({"duration":'800',message:response.msg,type:'warning',customClass:'zZindex'});

                }
              })
            }

            break
          default:
        }
      },
      go: function () {
        this.$store.dispatch('tagsView/delView', this.$route)
        this.$router.go(-1)
      },
      getProcessInstanceInfo: function (val) {
        getProcessInstanceInfo(val).then((response) => {
          if (response.code == 0) {
            if (response.data) {
              this.isRuning=false;
              //结束
            } else {
              //运行
              this.isRuning=true;
            }

          } else {
          }
        })
      }
    },
    watch: {
      newVal(newV, oldV) {
      },
      taskId(val){
        this.taskId=val;
      },
      value(val) {
        if (val) {
          getProcessInstanceInfo(val).then((response) => {
            if (response.code == 0) {


            } else {
            }
          })
        }
      }
    },
  }
</script>
